package 链表;

import common.ListNode;

/**
 * @author tmh
 * @date 2024/11/22 18:47
 * @description
 */
public class T206反转链表 {
    public ListNode reverseList(ListNode head) {
        ListNode pre = null;
        while (head != null) {
            ListNode after = head.next;
            head.next=pre;
            pre=head;
            head=after;
        }
        return pre;
    }
}
